//
//  constructors.hpp
//  learnC++
//
//  Created by apple on 2018/6/2.
//  Copyright © 2018年 yunfan.com. All rights reserved.
//

#ifndef constructors_hpp
#define constructors_hpp

#include <stdio.h>
#include <cassert>
#include <iostream>
//构造函数
class Fraction {
private:
    int m_numerator;
    int m_denominator;
    
public:
//    如果你的类没有其他的构造函数，C ++会自动为你生成一个公共的默认构造函数。
    //调用构造函数之前会先初始化成员变量
    Fraction(int num = 0,int den = 1){
        assert(den != 0);
        m_numerator = num;
        m_denominator = den;
    }
    
    int getNumerator() { return m_numerator; }
    void setNumerator(int value){m_numerator = value;}
    
    int getDenominator() { return m_denominator; }
    void setDenominator(int value){m_denominator = value;}
    
    double getValue() { return static_cast<double>(m_numerator) / m_denominator; }
    
};

#endif /* constructors_hpp */
